#coding: utf-8 

from math import sqrt,sin,cos,atan2

class Position:
	def __init__(self,x,y):
		self.x=x+0.0
		self.y=y+0.0
	
	def get_tuple(self):
		return (self.x,self.y)
		
	def add_dist(self,dist,teta):
		return Position(self.x+dist*cos(teta),self.y+dist*sin(teta))
	
	def dist_to(self,pos):
		if not isinstance(pos,Position):
			raise TypeError("Argument type must be Position")
		return sqrt((self.x-pos.x)**2+(self.y-pos.y)**2)
	
	def angle_to(self,pos):
		if not isinstance(pos,Position):
			raise TypeError("Argument type must be Position")
		
		return atan2(pos.y-self.y,pos.x-self.x)
		
	def __mul__(self,val):
		return Position(self.x*val,self.y*val)
	
	def __eq__(self,pos2):
		return self.x==pos2.x and self.y==pos2.y
	
	def __add__(self,pos2):
		return Position(self.x+pos2.x,self.y+pos2.y)
	
	def __sub__(self,pos2):
		return Position(self.x-pos2.x,self.y-pos2.y)
	
	def __hash__(self):
		return int(self.x*1000)+int(self.y*1000)*1000
	
	def __repr__(self):
		return "(%.2f,%.2f)" % (self.x,self.y)
	

